package org.gaaidou.ptarmigan.server.io;

import java.util.HashMap;
import java.util.Map;

public class HandlerRouter {
    private final Map<String, Handler> router = new HashMap<>();

    private final Handler notFoundHandler = new NotFoundHandler();

    public void add(String path, Handler handler) {
        router.put(path, handler);
    }

    public Handler route(String path) {
        if (!router.containsKey(path)) {
            return notFoundHandler;
        }
        return router.get(path);
    }

}
